BarracksRange = {}
BarracksRange.__index = BarracksRange
 
function BarracksRange.new()
    local instance = {
      _type = nil,
      ownerPlayer = nil,
      incomePerTurn = 20,
      tile = nil,
      capturePoints = 25,
      currentCapturePoints = 0,
      ownerObject = nil
    }
    
    setmetatable(instance, BarracksRange)
    return instance
end

setmetatable(BarracksRange,{__index = Building})

function BarracksRange:getCaptureTextbox()
  if self.captureTextbox ~= nil then
    return self.captureTextbox
  else
    return nil
  end
end

function BarracksRange:updateCaptureTextbox()
  self.captureTextbox:setString(tostring(self.currentCapturePoints) .. " / " .. tostring(self.capturePoints))
end

function BarracksRange:removeCaptureTextbox()
  MainLayer:removeProp(self.captureTextbox)
  
  for k, v in pairs(captureRenderTable) do
    if v == self.captureTextbox then
      table.remove(captureRenderTable, k)
      break
    end
  end
  self.captureTextbox = nil
end

function BarracksRange:showCaptureTextbox(x1, y1, x2, y2)
  if self.captureTextbox == nil then
    self.captureTextbox = MOAITextBox.new()
    self.captureTextbox:setPriority(20)
    self.captureTextbox:setStyle(styleHealthCaptureBox)
    self.captureTextbox:setRect(x1 - 5 , y1 - 22, x2 - 5, y2 - 22)
    self.captureTextbox:setAlignment(MOAITextBox.RIGHT_JUSTIFY, MOAITextBox.RIGHT_JUSTIFY)
    self.captureTextbox:setYFlip(true)
    self.captureTextbox:setString(tostring(self.currentCapturePoints) .. " / " .. tostring(self.capturePoints))
    MainLayer:insertProp(self.captureTextbox)
    captureRenderTable[table.getn(captureRenderTable) + 1] = self.captureTextbox
  end
end

function BarracksRange:getCurrentCapturePoints()
    return self.currentCapturePoints
end

function BarracksRange:increaseCurrentCapturePoints(_cap)
  local temp = self.currentCapturePoints
  self.currentCapturePoints = temp + _cap
end

function BarracksRange:resetCurrentCapturePoints()
    self.currentCapturePoints = 0
end

function BarracksRange:getCapturePoints()
    return self.capturePoints
end

function BarracksRange:setDecreaseCapturePoints(_decreaseBy)
    local temp = self.capturePoints
    self.capturePoints = temp - _decreaseBy
end

function BarracksRange:resetCapturePoints()
  self.capturePoints = 40
end

function BarracksRange:setTileWhichPlacedOn(_tile)
  self.tile = _tile
end

function BarracksRange:getTileWhichPlacedOn()
  return self.tile
end

function BarracksRange:getTypeBarracks()
  return "Range"
end

function BarracksRange:getTexturePlayerOne()
  return textureBarracksRangePlayerOne
end

function BarracksRange:getTexturePlayerTwo()
  return textureBarracksRangePlayerTwo
end

function BarracksRange:getTextureNeutral()
  return textureBarracksRangeNeutral
end

function BarracksRange:setOwner(_player)
  self.ownerPlayer = _player
end

function BarracksRange:getOwner()
  return self.ownerPlayer
end

function BarracksRange:setIncomePerTurn(_income)
  self.incomePerTurn = _income
end

function BarracksRange:getIncomePerTurn()
  return self.incomePerTurn
end

function BarracksRange:setType(_type)
  self._type = _type
end

function BarracksRange:getType()
  return self._type
end

function BarracksRange:getOwnerObject()
  return self.ownerObject
end

function BarracksRange:setOwnerObject(obj)
  self.ownerObject = obj
end
 
return BarracksRange